package Account;

/**
 * @author: zxy
 * @date: 2024/5/20 13:50
 * @version: 1.0
 */
public class Account {

    private int id;
    private double balance;
    private double annuallnterestRate; //年利率


    public Account(int id, double balance, double annuallnterestRate) {
        this.id = id;
        this.balance = balance;
        this.annuallnterestRate = annuallnterestRate;
    }

    public int getId(){
        return id;
    }

    public double getBalance(){
        return balance;
    }

    public double getAnnuallnterestRate(){
        return annuallnterestRate;
    }

    public void setld(int id){
        this.id = id;
    }

    public void setBalance(double balance){
        this.balance = balance;
    }

    public void setAnnuallnterestRate(double annuallnterestRate){
        this.annuallnterestRate = annuallnterestRate;
    }

    /**
     * 获取月利率
     * @return 月利率
     */
    public double getMonthlyInterest(){
        return annuallnterestRate / 12;
    }

    /**
     * 取款
     * @param amount 取款金额
     */
    public void withdraw(double amount){
        if (amount > balance){
            balance -= amount;
            System.out.println("已取款" + amount + "元");
        }
        else {
            System.out.println("余额不足");
        }
    }

    /**
     * 存款
     * @param amount 存款金额
     */
    public void deposit(double amount){
        balance += amount;
    }
}
